<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../react/react17.development.js"></script>
    <script src="../react/react-dom17.development.js"></script>
    <script src="../react/babel.min.js"></script>
</head>

<body>
    <div id="main"></div>
    <script type="text/babel">
        class Com extends React.Component {
            render() {
                return (<div>
                    <button onClick={this.run}>事件一</button>
                    <button onClick={this.run2}>事件二</button>
                    <button onClick={(e) => {
                        // 当前事件函数是箭头函数
                        console.log('事件函数', this); // 当前组件
                        console.log('事件函数', e); // 当前组件
                        this.run3(e);
                    }}>事件三</button>
                    <button onClick={(e) => this.run4(e)}>事件四</button>
                    <button onClick={this.run5.bind(this)}>事件五</button>

                </div>)
            }

            run5() {
                console.log('run55555555555', this); // 当前组件
            }
            run4(e) {
                console.log('run44444444444', this); // 当前组件
                console.log(e);
            }
            run() { //run= function(){}
                console.log('run函数', this); // this丢失 undefined
            }
            run2 = () => {
                console.log('run2', this); // 当前组件
            }
            run3(e) {
                console.log('run333333333333', this);
                console.log(e);
            }
        }
        ReactDOM.render(<Com />, document.getElementById('main'))
    </script>
</body>

</html>